package com.example.deviceinfo.data.repository

import com.example.deviceinfo.data.model.DeviceInfo
import com.example.deviceinfo.data.network.ApiPaginationResponse
import com.example.deviceinfo.data.network.ApiResponse
import com.example.deviceinfo.data.network.IDeviceApi
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.withContext
import retrofit2.Response
import javax.inject.Inject


class DeviceInfoRepository @Inject constructor(
    private val apiService: IDeviceApi
) {
    // 每页数量
    private val PAGE_SIZE = 20

    suspend fun fetchDevices(page: Int): Response<ApiPaginationResponse<DeviceInfo>> =
        withContext(Dispatchers.IO) {
            apiService.getDevices(page, PAGE_SIZE)
        }
}